package com.tw.playerdata;

public class Skill 
{
	private int level = 1;
	private int exp = 0;
	
	public Skill(String skillstring) {
		level = Integer.parseInt(skillstring.substring(0,skillstring.indexOf(',')));
		skillstring = skillstring.substring(skillstring.indexOf(',')+1);
		exp = Integer.parseInt(skillstring);
	}

	public Skill() {
	}

	public boolean giveExperience(int experience)
	{
		exp += experience;
		if(exp >= getRequiredExp())
		{
			level++;
			giveExperience(0);
			return true;
		}
		return false;
	}
	
	public int getRequiredExp()
	{
		return (int) (8 + Math.pow(2,level));
	}
	
	public int getLevel()
	{
		return level;
	}

	public String getSaveString() {
		return this.level+","+this.exp;
	}
}
